/*
**  Copyright (c) 2014 Michael Liu(michael.liu.point@gmail.com).
**
**  Project: Gateway Unified Management Platform
**  File:    dpif.h
**  Author:  Michael
**  Date:    06/25/2014
**
**  Purpose:
**    data path interfaces defines.
*/

#ifndef __DATAPATH_IF_MGR_H__
#define __DATAPATH_IF_MGR_H__

#ifdef __cplusplus
extern "C" {
#endif				/* __cplusplus */

/* Include files. */

#include "common.h"
#include "cmrc.h"
#include "list.h"
#include "dpdev.h"

/* Macro constant definitions. */

#define DP_IF_NAMESIZE							(16)

#define USERNAME_SIZE							(32)
#define PASSWORD_SIZE							(32)

#define DP_BR_MEMBER_MAX						(16)

#define WLAN_SSID_SIZE							(64 + 1)

#define WLAN_ENC_WPA_PSK_MAX_SIZE				(128 + 1)
#define WLAN_ENC_WEP_KEY_MAX_SIZE				(26 + 1)
#define WLAN_AP_ACL_NUM_MAX						(32)

/* Type definitions. */

	enum {
		eDP_IF_METHOD_CREATE = 10,
		eDP_IF_METHOD_ENABLE = 20,
		eDP_IF_METHOD_LINK = 30,
		eDP_IF_METHOD_CONNECT = 40,
		eDP_IF_METHOD_SET_LINKCFG = 50,
		eDP_IF_METHOD_GET_LINKCFG = 60,
		eDP_IF_METHOD_COLLECT_LINKSTAT = 70,
		eDP_IF_METHOD_GET_LINK_STATUS = 80,
		eDP_IF_METHOD_GET_LINKSTAT = 90,
		eDP_IF_METHOD_SET_NETCFG = 100,
		eDP_IF_METHOD_GET_NETCFG = 110,
		eDP_IF_METHOD_COLLECT_NETSTAT = 120,
		eDP_IF_METHOD_GET_NETSTAT = 130,
		eDP_IF_METHOD_GET_NET_STATUS = 140,
		eDP_IF_METHOD_DISCONNECT = 150,
		eDP_IF_METHOD_UNLINK = 160,
		eDP_IF_METHOD_DISABLE = 170,
		eDP_IF_METHOD_DESTORY = 180,
	} edp_if_method;

	enum {
		eDP_IF_TYPE_PPP_PPTP = 10,
		eDP_IF_TYPE_PPP_PPPOE = 20,
		eDP_IF_TYPE_PPP_MODEM = 30,
		eDP_IF_TYPE_BRIDGE = 40,
		eDP_IF_TYPE_VLAN = 50,
		eDP_IF_TYPE_ETH = 60,
		eDP_IF_TYPE_WLAN24G_AP = 70,
		eDP_IF_TYPE_WLAN24G_CLI = 80,
		eDP_IF_TYPE_WLAN5G_AP = 90,
		eDP_IF_TYPE_WLAN5G_CLI = 100,
		eDP_IF_TYPE_BONDING = 110,
	} edp_if_type;

	enum {
		eDP_IF_CLASS_NET_BASED = 10,
		eDP_IF_CLASS_IF_BASED = 20,
		eDP_IF_CLASS_DEV_BASED = 30,
	} edp_if_class;

	enum {
		eDP_IF_ATTR_LINK = 0,
		eDP_IF_ATTR_LINK_WPS = 1,
		eDP_IF_ATTR_NET = 2,
	} edp_if_attr;

	enum {
		eDP_IF_CONN_TYPE_NONE = 0,
		eDP_IF_CONN_TYPE_PPTP = 10,
		eDP_IF_CONN_TYPE_PPPOE = 20,
		eDP_IF_CONN_TYPE_PPP = 30,
		eDP_IF_CONN_TYPE_DHCP = 40,
		eDP_IF_CONN_TYPE_STATIC = 50,
	} edp_if_conn_type;

	enum {
		eDP_IF_DHCPD_TYPE_DISABLE,
		eDP_IF_DHCPD_TYPE_SMART,
		eDP_IF_DHCPD_TYPE_ENABLE,
	} edp_if_dhcpd_type;

	enum {
		eDP_IF_LINK_STATUS_NONE = 0,
		eDP_IF_LINK_STATUS_CREATED = 10,
		eDP_IF_LINK_STATUS_ENABLED = 20,
		eDP_IF_LINK_STATUS_DOWN = 30,
		eDP_IF_LINK_STATUS_UP = 40,
	} edp_if_link_status;

	enum {
		eDP_IF_NET_STATUS_DISCONNECTED = 0,
		eDP_IF_NET_STATUS_CONNECTED = 10,
	} edp_if_net_status;

	enum {
		eETH_IF_LINK_SPEED_AUTO,
		eETH_IF_LINK_SPEED_10M,
		eETH_IF_LINK_SPEED_100M,
		eETH_IF_LINK_SPEED_1000M,
	} eeth_if_link_speed;

	enum {
		eETH_IF_LINK_DUMPLEX_AUTO,
		eETH_IF_LINK_DUMPLEX_HALF,
		eETH_IF_LINK_DUMPLEX_FULL,
	} eethr_if_link_dumplex;

	enum {
		eWLAN_AUTH_MODE_MIN,
		eWLAN_AUTH_MODE_INVALID = eWLAN_AUTH_MODE_MIN,
		eWLAN_AUTH_MODE_OPEN,
		eWLAN_AUTH_MODE_SHARED,
		eWLAN_AUTH_MODE_WEPAUTO,
		eWLAN_AUTH_MODE_WPAPSK,
		eWLAN_AUTH_MODE_WPANONE,
		eWLAN_AUTH_MODE_WPA2PSK,
		eWLAN_AUTH_MODE_WPAPSKWPA2PSK,
		eWLAN_AUTH_MODE_WPA,
		eWLAN_AUTH_MODE_WPA2,
		eWLAN_AUTH_MODE_WPAWPA2,
		eWLAN_AUTH_MODE_MAX,
	} ewlan_auth_mode;

	enum {
		eWLAN_ENC_METHOD_MIN,
		eWLAN_ENC_METHOD_INVALID = eWLAN_ENC_METHOD_MIN,
		eWLAN_ENC_METHOD_NONE,
		eWLAN_ENC_METHOD_WEP,
		eWLAN_ENC_METHOD_TKIP,
		eWLAN_ENC_METHOD_AES,
		eWLAN_ENC_METHOD_CCMP = eWLAN_ENC_METHOD_AES,
		eWLAN_ENC_METHOD_TKIP_AES,
		eWLAN_ENC_METHOD_TKIP_CCMP = eWLAN_ENC_METHOD_TKIP_AES,
		eWLAN_ENC_METHOD_MAX,
	} ewlan_enc_method;

	enum {
		eWLAN_WEP_KEY_TYPE_MIN,
		eWLAN_WEP_KEY_TYPE_INVALID = eWLAN_WEP_KEY_TYPE_MIN,
		eWLAN_WEP_KEY_TYPE_ASCII,
		eWLAN_WEP_KEY_TYPE_HEX,
		eWLAN_WEP_KEY_TYPE_MAX,
	} ewlan_wep_key_type;

	enum {
		eWLAN24G_MODE_B_ONLY,
		eWLAN24G_MODE_G_ONLY,
		eWLAN24G_MODE_N_ONLY,
		eWLAN24G_MODE_BG_MIX,
		eWLAN24G_MODE_GN_MIX,
		eWLAN24G_MODE_BGN_MIX,
		eWLAN24G_MODE_AUTO = eWLAN24G_MODE_GN_MIX,
		eWLAN24G_MODE_UNKNOWN,
	} ewlan_24g_mode;

	enum {
		eWLAN5G_MODE_A_ONLY,
		eWLAN5G_MODE_N_ONLY,
		eWLAN5G_MODE_AC_ONLY,
		eWLAN5G_MODE_AN_MIX,
		eWLAN5G_MODE_NAC_MIX,
		eWLAN5G_MODE_ANAC_MIX,
		eWLAN5G_MODE_AUTO = eWLAN5G_MODE_ANAC_MIX,
		eWLAN5G_MODE_UNKNOWN,
	} ewlan_5g_mode;

	enum {
		eWLAN_WPS_DPID_NOT_SPEC,
		eWLAN_WPS_DPID_PIN,
		eWLAN_WPS_DPID_PBC,
	} ewlan_dpid;

	enum {
		eWLAN_NETWORK_TYPE_ADHOC,
		eWLAN_NETWORK_TYPE_INFRASTRUCTURE,
	} ewlan_network_type;

	enum {
		eWLAN_BW_20M,
		eWLAN_BW_20M_40M,
		eWLAN_BW_20M_40M_80M,
		eWLAN_BW_40M,
		eWLAN_BW_40M_80M,
		eWLAN_BW_80M,
	} ewlan_bw;

	enum {
		eWLAN_ACL_NONE,
		eWLAN_ACL_WHITELIST,
		eWLAN_ACL_BLACKLIST,
	} ewlan_acl_type;

	enum {
		eWLAN_BG_PROTECT_AUTO,
		eWLAN_BG_PROTECT_ON,
		eWLAN_BG_PROTECT_OFF,
	} ewlan_bg_protect;

	enum {
		eWLAN_EXT_CHANNEL_NONE,
		eWLAN_EXT_CHANNEL_ABOVE,
		eWLAN_EXT_CHANNEL_BELOW,
	} ewlan_ext_channel;

	enum {
		ePPPOE_CONN_TYPE_STAY,
		ePPPOE_CONN_TYPE_MANUAL,
	} epppoe_conn_type;

	enum {
		eLED_STATUS_SIGNAL_NONE,
		eLED_STATUS_SIGNAL_LOW,
		eLED_STATUS_SIGNAL_NORMAL,
		eLED_STATUS_SIGNAL_HIGH,
		eLED_STATUS_SCAN,
		eLED_STATUS_WPS_PROCESS,
		eLED_STATUS_WPS_SUCCESS,
		eLED_STATUS_WPS_FAIL,
		eLED_STATUS_WPS_OVERLAP,
		eLED_STATUS_INIT,
	} edp_if_led_status;

	enum {
		eETH_IF_LISTCFG_MASK0_SPEED,
		eETH_IF_LISTCFG_MASK0_DUMPLEX,
		eETH_IF_LISTCFG_MASK0_ALL = ((unsigned long)~((unsigned long)0)),
	} eeth_if_linkcfg_mask0;

	enum {
		eVLAN_IF_LINKCFG_MASK0_BASEIF,
		eVLAN_IF_LINKCFG_MASK0_VLANID,
		eVLAN_IF_LINKCFG_MASK0_ALL = ((unsigned long)~((unsigned long)0)),
	} evlan_if_linkcfg_mask0;

	enum {
		eWLAN_AP_IF_LINKCFG_MASK0_SSID,
		eWLAN_AP_IF_LINKCFG_MASK0_MODE,
		eWLAN_AP_IF_LINKCFG_MASK0_BW,
		eWLAN_AP_IF_LINKCFG_MASK0_SGI,
		eWLAN_AP_IF_LINKCFG_MASK0_TX_PWR,
		eWLAN_AP_IF_LINKCFG_MASK0_CHANNEL,
		eWLAN_AP_IF_LINKCFG_MASK0_BEACON_ITV,
		eWLAN_AP_IF_LINKCFG_MASK0_HIDE_SSID,
		eWLAN_AP_IF_LINKCFG_MASK0_STA_ISOLATE,
		eWLAN_AP_IF_LINKCFG_MASK0_AUTH_MODE,
		eWLAN_AP_IF_LINKCFG_MASK0_ENC_METHOD,
		eWLAN_AP_IF_LINKCFG_MASK0_SEC_KEY,
		eWLAN_AP_IF_LINKCFG_MASK0_ACL,
		eWLAN_AP_IF_LINKCFG_MASK0_WMM_APSD_DLS,
		eWLAN_AP_IF_LINKCFG_MASK0_BG_PROTECTION,
		eWLAN_AP_IF_LINKCFG_MASK0_HT_EXTCHA,
		eWLAN_AP_IF_LINKCFG_MASK0_REKEY,
		eWLAN_AP_IF_LINKCFG_MASK0_RTSTHRESHOLD,
		eWLAN_AP_IF_LINKCFG_MASK0_FRAGTHRESHOLD,
		eWLAN_AP_IF_LINKCFG_MASK0_DTIMPERIOD,
		eWLAN_AP_IF_LINKCFG_MASK0_TXBURST,
		eWLAN_AP_IF_LINKCFG_MASK0_PKTAGGREGATE,
		eWLAN_AP_IF_LINKCFG_MASK0_GREENAP,
		eWLAN_AP_IF_LINKCFG_MASK0_GREENFIELD,
		eWLAN_AP_IF_LINKCFG_MASK0_APENABLE,
		eWLAN_AP_IF_LINKCFG_MASK0_ALL = ((unsigned long)~((unsigned long)0)),
	} ewlan_ap_if_linkcfg_mask0;

	enum {
		eWLAN_IF_LINKCFG_MASK1_WPS_ENABLE,
		eWLAN_IF_LINKCFG_MASK1_WPS_METHOD,
		eWLAN_IF_LINKCFG_MASK1_WPS_RESET,
		eWLAN_IF_LINKCFG_MASK1_WPS_ALL = ((unsigned long)~((unsigned long)0)),
	} ewlan_ap_if_linkcfg_mask1;

	enum {
		eWLAN_CLI_IF_LINKCFG_MASK0_SSID,
		eWLAN_CLI_IF_LINKCFG_MASK0_MAC,
		eWLAN_CLI_IF_LINKCFG_MASK0_CHANNEL,
		eWLAN_CLI_IF_LINKCFG_MASK0_AUTH_MODE,
		eWLAN_CLI_IF_LINKCFG_MASK0_ENC_METHOD,
		eWLAN_CLI_IF_LINKCFG_MASK0_SEC_KEY,
		eWLAN_CLI_IF_LINKCFG_MASK0_ALL = ((unsigned long)~((unsigned long)0)),
	} ewlan_cli_linkcfg_mask0;

	enum {
		eBRIDGE_IF_LINKCFG_MASK0_MEMBERS,
		eBRIDGE_IF_LINKCFG_MASK0_UPLINK,
		eBRIDGE_IF_LINKCFG_MASK0_ALL = ((unsigned long)~((unsigned long)0)),
	} ebridge_if_linkcfg_mask0;

	enum {
		eWLAN_LINKSTAT_MASK0_QUERY,
		eWLAN_LINKSTAT_MASK0_CANCEL,
		eWLAN_LINKSTAT_MASK0_ALL = ((unsigned long)~((unsigned long)0)),
	} ewlan_linkstat_mask0;

	enum {
		eDP_IF_NETCFG_MASK1_PPTP_USERNAME,
		eDP_IF_NETCFG_MASK1_PPTP_PASSWORD,
		eDP_IF_NETCFG_MASK1_PPTP_SERVERIP,
		eDP_IF_NETCFG_MASK1_PPTP_ALL = ((unsigned long)~((unsigned long)0)),
	} edp_if_netcfg_mask1_pptp;

	enum {
		eDP_IF_NETCFG_MASK1_MODEM_DIALNUM,
		eDP_IF_NETCFG_MASK1_MODEM_ALL = ((unsigned long)~((unsigned long)0)),
	} edp_if_netcfg_mask1_modem;

	enum {
		eDP_IF_NETCFG_MASK1_PPPOE_CONNTYPE,
		eDP_IF_NETCFG_MASK1_PPPOE_USERNAME,
		eDP_IF_NETCFG_MASK1_PPPOE_PASSWORD,
		eDP_IF_NETCFG_MASK1_PPPOE_ALL = ((unsigned long)~((unsigned long)0)),
	} edp_if_netcfg_mask1_pppoe;

	enum {
		eDP_IF_NETCFG_MASK1_STATIC_IPADDR,
		eDP_IF_NETCFG_MASK1_STATIC_NETMASK,
		eDP_IF_NETCFG_MASK1_STATIC_DEFAULTGW,
		eDP_IF_NETCFG_MASK1_ALL = ((unsigned long)~((unsigned long)0)),
	} edp_if_netcfg_mask1_static;

	enum {
		eDP_IF_NETCFG_MASK0_CONNTYPE,
		eDP_IF_NETCFG_MASK0_MTU,
		eDP_IF_NETCFG_MASK0_MANUAL_DNS,
		eDP_IF_NETCFG_MASK0_DHCPD,
		eDP_IF_NETCFG_MASK0_ALL = ((unsigned long)~((unsigned long)0)),
	} edp_if_netcfg_mask0;

	enum {
		eDP_IF_LINKCFG_MASK7_LOAD_CFG,
	} edp_if_linkcfg_mask7;

	typedef struct data_paths tdata_paths;

	typedef struct {
		char mac[RC_MAC_STR_MAX_SIZE];
	} tmac_addr_str;

	typedef struct {
		char value[WLAN_ENC_WEP_KEY_MAX_SIZE];
	} twlan_wep_key;

	typedef struct {
		unsigned char default_id;
		twlan_wep_key key[4];
	} twlan_wep_sec_key;

	typedef union {
		char wpa_psk[WLAN_ENC_WPA_PSK_MAX_SIZE];
		twlan_wep_sec_key wep_key;
	} twlan_sec_key;

	typedef struct {
		unsigned char speed;	/* eeth_if_link_speed */
		unsigned char dumplex;	/* eethr_if_link_dumplex */
	} teth_if_linkcfg;

	typedef struct {
		unsigned char linked;	/* eBOOL_TRUE or eBOOL_FALSE */
		unsigned char speed;	/* eeth_if_link_speed */
		unsigned char dumplex;	/* eethr_if_link_dumplex */
	} teth_if_link_status;

	typedef struct {
		char base_if[DP_IF_NAMESIZE];
		unsigned int vlan_id;
	} tvlan_if_linkcfg;

	typedef struct {
		unsigned char acl_type;	/* ewlan_acl_type */
		unsigned char counter;
		tmac_addr_str acl[WLAN_AP_ACL_NUM_MAX];
	} twlan_ap_acl;

	typedef struct {
		char ssid[WLAN_SSID_SIZE];
		unsigned char mode;	/* ewlan_24g_mode or ewlan_5g_mode */
		unsigned char bw;	/* ewlan_bw */
		unsigned char sgi;	/* eBOOL_TRUE or eBOOL_FALSE */
		unsigned char tx_pwr;	/* 10 - 100 */
		unsigned short channel;	/* 0 - auto */
		unsigned short beacon_interval;
		unsigned char region;
		unsigned char hide_ssid;	/* eBOOL_TRUE or eBOOL_FALSE */
		unsigned char sta_isolate;	/* eBOOL_TRUE or eBOOL_FALSE */
		unsigned char auth_mode;	/* ewlan_auth_mode */
		unsigned char enc_method;	/* ewlan_enc_method */
		unsigned char wmm_apsd;	/* eBOOL_TRUE or eBOOL_FALSE */
		unsigned char wmm_dls;	/* eBOOL_TRUE or eBOOL_FALSE */
		unsigned char bg_protection;	/* ewlan_bg_protect */
		unsigned char ht_extcha;	/* ewlan_ext_channel */
		unsigned char dtimperiod;	/* 1 - 255 */
		unsigned char txburst;	/* eBOOL_TRUE or eBOOL_FALSE */
		unsigned char pktaggregate;	/* eBOOL_TRUE or eBOOL_FALSE */
		unsigned char greenap;	/* eBOOL_TRUE or eBOOL_FALSE */
		unsigned char greenfield;	/* eBOOL_TRUE or eBOOL_FALSE */
		unsigned char radio_on;	/* eBOOL_TRUE or eBOOL_FALSE */
		unsigned long rekey;	/* 0 - 0x3FFFFFFF */
		unsigned int rtsthreshold;	/* 1 - 2347 */
		unsigned int fragthreshold;	/* 256 - 2346 */
		twlan_sec_key sec_key;
		twlan_ap_acl acl;	/* Just accept less than WLAN_AP_ACL_NUM_MAX. */
		unsigned char wps_enable;	/* eBOOL_TRUE or eBOOL_FALSE */
		unsigned char wps_configed;	/* eBOOL_TRUE or eBOOL_FALSE */
		unsigned char wps_method;	/* ewlan_dpid. */
		unsigned long wps_pin;	/* show only. */
		unsigned long wps_client_pin;	/* input value. */
	} twlan_ap_if_linkcfg;

	typedef struct {
		tmac_addr_str cli_mac;
		unsigned long online_time;	/* seconds */
		unsigned char power_save;	/* eBOOL_TRUE or eBOOL_FALSE. */
		unsigned char bw;	/* ewlan_bw */
		unsigned char rssi0;	/* absolute value, true value: 0 - rssi. */
		unsigned char rssi1;	/* absolute value, true value: 0 - rssi. */
		unsigned char rssi2;	/* absolute value, true value: 0 - rssi. */
		unsigned long tx_rate;	/* bit rate bits/s. */
		unsigned long rx_rate;	/* bit rate bits/s. */
	} twlan_ap_if_link_entry;

	typedef struct {
		unsigned char counter;
		unsigned short wps_status;
		twlan_ap_if_link_entry clients[0];
	} twlan_ap_if_link_status;

	typedef struct {
		unsigned char enable;
		char ssid[WLAN_SSID_SIZE];
		char mac[RC_MAC_STR_MAX_SIZE];
		unsigned char channel;	/* we need channel info for client if. */
		unsigned char ext_channel;	/* ewlan_ext_channel */
		unsigned char auth_mode;	/* ewlan_auth_mode */
		unsigned char enc_method;	/* ewlan_enc_method */
		twlan_sec_key sec_key;
	} twlan_cli_if_linkcfg;

	typedef struct {
		char ssid[WLAN_SSID_SIZE];
		char bssid[RC_MAC_STR_MAX_SIZE];
		unsigned char mode;	/* ewlan_24g_mode or ewlan_5g_mode */
		unsigned char network_type;	/* ewlan_network_type */
		unsigned char wps;	/* eBOOL_TRUE or eBOOL_FALSE */
		unsigned char dpid;	/* ewlan_dpid */
		unsigned char linked;	/* eBOOL_TRUE or eBOOL_FALSE. */
		unsigned char channel;
		unsigned char ext_channel;	/* ewlan_ext_channel */
		unsigned char signal;	/* it's a percent value. */
		unsigned char auth_mode;	/* ewlan_auth_mode */
		unsigned char enc_method;	/* ewlan_enc_method */
		unsigned long tx_rate;	/* only for getlinkstatus. */
		unsigned long rx_rate;	/* only for getlinkstatus. */
	} twlan_cli_if_link_entry;

	typedef struct {
		unsigned char counter;
		twlan_cli_if_link_entry aps[0];
	} twlan_cli_if_link_status;

	typedef struct wsc_profile {
		unsigned short wsc_configured;
		unsigned char wsc_ssid[32 + 1];
		unsigned short wsc_auth_mode;
		unsigned short wsc_encryp_type;
		unsigned char wsc_default_key_idx;
		unsigned char wsc_wpapsk[64 + 1];
	} twlan_wsc_profile;

	typedef struct {
		char members[DP_BR_MEMBER_MAX][DP_IF_NAMESIZE];
		char uplink[DP_IF_NAMESIZE];
	} tbridge_if_linkcfg;

	typedef struct {
		char username[USERNAME_SIZE];
		char password[PASSWORD_SIZE];
		char serverip[RC_IPV4_STR_MAX_SIZE];
	} tpptp_netcfg;

	typedef struct {
		char dialnumber[16];
	} tppp_modem_netcfg;

	typedef struct {
		unsigned char conntype;	/* epppoe_conn_type */
		char username[USERNAME_SIZE];
		char password[PASSWORD_SIZE];
	} tpppoe_netcfg;

	typedef struct {
		char dns1[RC_IPV4_STR_MAX_SIZE];
		char dns2[RC_IPV4_STR_MAX_SIZE];
	} tdp_if_dns;

	typedef struct {
		char ipaddr[RC_IPV4_STR_MAX_SIZE];
		char netmask[RC_IPV4_STR_MAX_SIZE];
		char defaultgw[RC_IPV4_STR_MAX_SIZE];
	} tstatic_netcfg;

	typedef struct {
		unsigned char dhcpd_type;	/* edp_if_dhcpd_type */
		char start[RC_IPV4_STR_MAX_SIZE];
		char end[RC_IPV4_STR_MAX_SIZE];
		char netmask[RC_IPV4_STR_MAX_SIZE];
		char defaultgw[RC_IPV4_STR_MAX_SIZE];
		unsigned long lease;
		tdp_if_dns dns;
	} tdhcpd_cfg;

	typedef struct {
		unsigned char conntype;	/* edp_if_conn_type */
		unsigned char man_dns;	/* eBOOL_TRUE or eBOOL_FALSE. */
		tdp_if_dns dns;	/* depend on man_dns == eBOOL_TRUE */
		int mtu;	/* MTU size. 0 for auto. */
		union {
			tpptp_netcfg pptp_conn;	/* eDP_IF_CONN_TYPE_PPTP */
			tppp_modem_netcfg modem_conn;	/* eDP_IF_CONN_TYPE_PPP */
			tpppoe_netcfg pppoe_conn;	/* eDP_IF_CONN_TYPE_PPPOE */
			tstatic_netcfg static_conn;	/* eDP_IF_CONN_TYPE_STATIC */
		};
		tdhcpd_cfg dhcpd_cfg;
	} tdp_if_netcfg;

	typedef struct {
		char ipaddr[RC_IPV4_STR_MAX_SIZE];
		char mac[RC_MAC_STR_MAX_SIZE];
		unsigned long expire;
	} tdhcp_lease_entry;

	typedef struct {
		int mtu;	/* MTU size. 0 for auto. */
		char ipaddr[RC_IPV4_STR_MAX_SIZE];
		char netmask[RC_IPV4_STR_MAX_SIZE];
		char defaultgw[RC_IPV4_STR_MAX_SIZE];
		tdp_if_dns dns;
		unsigned char dhcp_lease_counter;
		tdhcp_lease_entry dhcp_lease_entry[0];
	} tdp_if_netstatus;

	typedef struct dp_if tdp_if;
	struct dp_if {
		/* attributes */
		char name[DP_IF_NAMESIZE];
		unsigned char type;	/* edp_if_type */
		unsigned char cls;	/* edp_if_class */
		unsigned char attr;	/* edp_if_attr */
		unsigned char prepare;	/* eBOOL_TURE or eBOOL_FALSE */
		tdp_dev *based_on_dev;	/* based on dev pointer. */
		struct {
			void *led;
			int status;
			int counter;
		} led;		/* based on LED dev. */
		unsigned char linkstatus;	/* edp_if_link_status */
		unsigned char connstatus;	/* edp_if_net_status */
		tdp_if *data_if;	/* br member -> br; eth -> pppoe; eth -> pptp; br -> uplink .etc */
		void *data_paths;
		unsigned char dp_idx;	/* data path index. */
		struct list_head all_list;	/* if list node. */
		struct list_head hierarchy;	/* be base list node. */
		struct list_head based_on_if;	/* based on if list head. */
		int netcfg_size;
		void *netcfg;
		int linkcfg_size;
		void *linkcfg;
		void *priv;
		struct {
			unsigned long status;
			unsigned long cfg_method;
			unsigned char counter;
		} wps;

		/* method */
		 e_ret(*create) (tdp_if * dp_if);
		 e_ret(*destroy) (tdp_if * dp_if);
		 e_ret(*enable) (tdp_if * dp_if);
		 e_ret(*disable) (tdp_if * dp_if);
		 e_ret(*setlinkcfg) (tdp_if * dp_if, void *linkcfg, tmask * mask);
		 e_ret(*getlinkcfg) (tdp_if * dp_if, void **linkcfg, int *size, tmask * mask);
		 e_ret(*link) (tdp_if * dp_if);
		 e_ret(*unlink) (tdp_if * dp_if);
		 e_ret(*collectlinkstat) (tdp_if * dp_if);
		 e_ret(*getlinkstat) (tdp_if * dp_if, void **linkstat, int *size, tmask * mask);
		 e_ret(*getlinkstatus) (tdp_if * dp_if, void **status, int *size, tmask * mask);
		 e_ret(*setnetcfg) (tdp_if * dp_if, void *netcfg, tmask * mask);
		 e_ret(*getnetcfg) (tdp_if * dp_if, void **netcfg, int *size, tmask * mask);
		 e_ret(*connect) (tdp_if * dp_if);
		 e_ret(*disconnect) (tdp_if * dp_if);
		 e_ret(*collectnetstat) (tdp_if * dp_if);
		 e_ret(*getnetstat) (tdp_if * dp_if, void **netstat, int *size, tmask * mask);
		 e_ret(*getnetstatus) (tdp_if * dp_if, void **status, int *size, tmask * mask);
		 e_ret(*setledstatus) (tdp_if * dp_if, int status);
	};

/* External function declarations. */

	extern e_ret dp_ifs_init(void *dp);

	extern e_ret dpif_getlinkcfg_common(tdp_if * dp_if, void **linkcfg, int *size, tmask * mask);
	extern e_ret dpif_getnetcfg_common(tdp_if * dp_if, void **netcfg, int *size, tmask * mask);

	extern e_ret dpif_setnetcfg_common(tdp_if * dp_if, void *netcfg, tmask * mask);
	extern e_ret dpif_connect_common(tdp_if * dp_if);
	extern e_ret dpif_getnetstatus_common(tdp_if * dp_if, tdp_if_netstatus ** netstatus, int *netstatus_size);

	extern e_ret dp_wlan_cli_start_wps(tdp_if * dp_if, unsigned char wps_method, unsigned long pin);
	extern e_ret dp_wlan_ap_start_wps(tdp_if * dp_if, unsigned char wps_method, unsigned long pin);

	extern e_ret dp_if_do_cmd(tdp_if * dp_if, unsigned char method, ...);	/* Terminate with NULL. */

	extern e_ret bridge_set_uplink_if(tdata_paths * dp, tdp_if * br_if, const char *uplink_ifname);
	extern e_ret bridge_add_member_if(tdata_paths * dp, tdp_if * br_if, tdp_if * member_if);
	extern e_ret bridge_remove_member_if(tdata_paths * dp, tdp_if * br_if, tdp_if * member_if);

/* Macro API definitions. */

#define dp_if_set_led_status(dp_if, status) \
do {																		\
	tdp_if *dp_if_ptr = (dp_if);											\
	if ((dp_if_ptr != NULL) && (dp_if_ptr->setledstatus != NULL)) {			\
		dp_if_ptr->setledstatus(dp_if_ptr, status);							\
	} else {																\
		sysmgr_dbg("dp_if [%p] setledstatus[%p], NULL pointer\n",			\
			dp_if_ptr, (dp_if_ptr == NULL) ? NULL : dp_if_ptr->setledstatus);\
	}																		\
} while (0)

/* Global variable declarations. */

#ifdef __cplusplus
}				/* extern "C" */
#endif				/* __cplusplus */
#endif				/* __DATAPATH_IF_MGR_H__ */
